package com.kuang.springcloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @program: springcloud
 * @description:
 * @author: 陈恩涛
 * @create: 2020-12-15 15:11
 **/
@Configuration
public class ConfigBean {//Configuration -- spring applicationContext.xml

    //IRule
    // AvailabilityFilteringRule:先过滤掉已经跳闸，访问故障的服务，剩下的进行轮询
    //RoundRobinRule:轮询,默认
    //RandomRule:随机
    //RetryRule:会先按照轮询获取服务~，如果服务获取失败，会在指定的时间内重试
    @Bean
    @LoadBalanced()       //配置负载均衡实现RestTemplate,Ribbon
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }
}
